cd "C:\Users\m1049\Dropbox\CPS Replication Final"

use main.dta,replace

* Table 1: main results

xtreg watersupply treatment_binary i.year, fe vce(cluster id)

xtreg road treatment_binary i.year, fe vce(cluster id)

xtreg lib treatment_binary i.year, fe vce(cluster id)

xtreg center treatment_binary i.year, fe vce(cluster id)

xtreg max treatment_binary i.year, fe vce(cluster id)

* Table 2: average controlled direct effects (implemented via R; please see "ACDE" R script)

* Table 3: effect heterogeneity by local elite capture

xtreg watersupply treatment_binary##c.elite_capture i.year, fe vce(cluster id)

xtreg road treatment_binary##c.elite_capture i.year, fe vce(cluster id)

xtreg lib treatment_binary##c.elite_capture i.year, fe vce(cluster id)

xtreg center treatment_binary##c.elite_capture i.year, fe vce(cluster id)

xtreg max treatment_binary##c.elite_capture i.year, fe vce(cluster id)

** Supplementary information

* Health services (not included and presented in the anlysis)

xtreg per_patients treatment_binary i.year, fe vce(cluster id)

xtreg beds_PerThousandPeople treatment_binary i.year, fe vce(cluster id)

* wild cluster bootstrap p-values

xtreg watersupply treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary,  bootcluster(ct) nograph weight(webb) seed(123456789)

xtreg road treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary,  bootcluster(ct) nograph weight(webb) seed(123456789)

xtreg lib treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary,  bootcluster(ct) nograph weight(webb) seed(123456789)

xtreg center treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary,  bootcluster(ct) nograph weight(webb) seed(123456789)

xtreg max treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary,  bootcluster(ct) nograph weight(webb) seed(123456789)

* Aggregate analysis at the county level (clustered idandard error by county/municipality. Wild cluster bootstrap p-values are computed)

preserve
xtreg watersupply treatment_binary i.year, fe vce(cluster id)
collapse (mean) watersupply treatment_binary if e(sample), by(ct year)
xtset ct year
xtreg watersupply treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary, bootcluster(ct) nograph weight(webb) seed(123456789)
restore

preserve
xtreg road treatment_binary i.year, fe vce(cluster id)
collapse (mean) road treatment_binary if e(sample), by(ct year)
xtset ct year
xtreg road treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary, bootcluster(ct) nograph weight(webb) seed(123456789)
restore

preserve
xtreg lib treatment_binary i.year, fe vce(cluster id)
collapse (mean) lib treatment_binary if e(sample), by(ct year)
xtset ct year
xtreg lib treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary, bootcluster(ct) nograph weight(webb) seed(123456789)
restore

preserve
xtreg center treatment_binary i.year, fe vce(cluster id)
collapse (mean) center treatment_binary if e(sample), by(ct year)
xtset ct year
xtreg center treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary, bootcluster(ct) nograph weight(webb) seed(123456789)
restore

preserve
xtreg max treatment_binary i.year, fe vce(cluster id)
collapse (mean) max treatment_binary if e(sample), by(ct year)
xtset ct year
xtreg max treatment_binary i.year, fe vce(cluster ct)
boottest treatment_binary, bootcluster(ct) nograph weight(webb) seed(123456789)
restore

* Placebo teids

* road

preserve 

drop if year<2006 |  year>2014

keep if year<=2009

forvalues i=2006/2009{

gen post`i'=1 if year>=`i'
recode post`i' .=0

xtreg road treatment##post`i' i.year, fe vce(cluster id)
 
}

restore

* community libraries and activity centers

preserve

keep if year<=2009 & year>=2008

forvalues i=2008/2009{
    
gen post`i'=1 if year>=`i'
recode post`i' .=0

xtreg lib treatment##post`i' i.year, fe vce(cluster id)

xtreg center treatment##post`i' i.year, fe vce(cluster id)

}

restore

* max storage

preserve

keep if year<=2009

forvalues i=2008/2009{
   
gen post`i'=1 if year>=`i'
recode post`i' .=0

xtreg max treatment##post`i' i.year, fe vce(cluster id)

}

restore

* Entropy Balancing

xtreg watersupply treatment_binary i.year [aweight=weights_water],fe vce(cluster id)

xtreg road treatment_binary i.year [aweight=weights_road], fe vce(cluster id)

xtreg lib treatment_binary i.year [aweight= weight_lib],fe vce(cluster id)

xtreg center treatment_binary i.year [aweight= weight_center],fe vce(cluster id)

xtreg max treatment_binary i.year [aweight=weights_allcapacity], fe vce(cluster id)

* Near border Analysis

reg treatment median_income population birth death natural_increase net_migration population_density sex_ratio temperature rainfall primary_education if year<=2009 & boundary==1, r

xtreg watersupply treatment_binary i.year if boundary==1,fe vce(cluster id)
xtreg road treatment_binary i.year if boundary==1, fe vce(cluster id)
xtreg lib treatment_binary i.year if boundary==1, fe vce(cluster id)
xtreg center treatment_binary i.year if boundary==1, fe vce(cluster id)
xtreg max treatment_binary i.year if boundary==1, fe vce(cluster id)

* Placebo outcome variables (Centralization should not affect the number of churches)

xtreg church treatment_binary i.year,fe vce(cluster id)

xtreg logchurch treatment_binary i.year,fe vce(cluster id)

* Sensitivity analysis (see "sensitivity analysis" R script)

* Combining all the five dependent variables into an index by averaging five idandardized outcome variables

foreach var of varlist water road lib center max{

egen mean`var'=mean(`var')
egen sd`var' = sd(`var')
gen z`var'=(`var'-mean`var')/sd`var'

}

gen zroad_reversed=-zroad
gen index=(zwatersupply+zroad_reversed+zlib+zcenter+zmax)/5

xtreg index treatment_binary i.year,fe vce(cluster id)

* Effect heterogeneity by political awareness (the share of residents with a primary education or less as a measure of political awareness) 

xtreg watersupply treatment_binary##c.primary i.year, fe vce(cluster id)

xtreg road treatment_binary##c.primary i.year, fe vce(cluster id)

xtreg lib treatment_binary##c.primary i.year, fe vce(cluster id)

xtreg center treatment_binary##c.primary i.year, fe vce(cluster id)

xtreg max treatment_binary##c.primary i.year, fe vce(cluster id)

* budget priorities (the analysis does not include Taipei City and the merger of Kaohsiung City and Kaohsiung County; data on Kaohsiung City's pre-treatment period budget are not available)

use budget.dta,replace

xtreg transportation_expenditure_share DiD i.year if ct!=23 & ct!=22 & ct!=14, fe cluster(ct_id)

xtreg community_expenditure_share DiD i.year  if ct!=23 & ct!=22 & ct!=14, fe cluster(ct_id)

xtreg culture_expenditure_share DiD i.year  if ct!=23 & ct!=22 & ct!=14, fe cluster(ct_id)

* TEDS survey analysis

use teds_survey.dta,replace

reg total i.year i.town_id treatment##post, cluster(town_id)

reg total i.year##treatment i.town_id, cluster(town_id)

* Bacon decomposition

use main.dta,replace

* water
preserve
drop if watersupply==.
ddtiming watersupply treatment_binary, i(id) t(year)
restore

* road
preserve
drop if road==.
ddtiming road treatment_binary, i(id) t(year)
restore

* lib
preserve
xtreg lib treatment_binary i.year, fe vce(cluster id)
drop if lib==.
ddtiming lib treatment_binary, i(id) t(year)
restore

* center
preserve
xtreg center treatment_binary i.year, fe vce(cluster id)
drop if center==.
ddtiming center treatment_binary, i(id) t(year)
restore

* columbaria (no staggered treatment timing)
